#include <iostream>
#include <string>
#include <vector>

using namespace std;

class ConcatinatedString {
private:
    const string& firstStr;
    const string& secondStr;
public:
    ConcatinatedString(const string& first, const string& second) : firstStr(first), secondStr(second) {}
    char operator[](size_t n) {
        if(n < firstStr.size()) {
            return firstStr[n];
        } else if(n == firstStr.size()) {
            return static_cast<char>(0);
        } else if(n < firstStr.size() + secondStr.size() + 1) {
            return secondStr[n - firstStr.size() - 1];
        }
    }
    size_t length() {
        return firstStr.size() + secondStr.size() + 1;
    }
    size_t firstLength() {
        return firstStr.size();
    }
    size_t secondLength() {
        return secondStr.length();
    }
};

void zCalculation(ConcatinatedString& str, vector<int>& z) {
    int strLen=str.length();

    int r = 1; //позиция самого правоого z-блока
    size_t right = 1;
    
    for (size_t i=1; i<strLen; ++i) {
        if (r + z[r] - 1 <= i) {
            z[i] = strLen - i;
            for (size_t j = i; j < strLen; ++j) {
                if (str[j] != str[j - i]) {
                    z[i] = j - i;
                    break;
                }
            }
            r=i;
        } else {
            if (z[i - r] < (r + z[r] - i)) {
                z[i] = z[i - r];
            } else {
                z[i] = strLen - i;
                for (size_t j=r + z[r]; j<strLen; ++j) {
                    if (str[j] != str[j - i]) {
                        z[i] = j - i;
                        break;
                    }
                }
                r=i;
            }
        }
    }
}

int main() {
    string str, subStr;
    cin >> str >> subStr;
    ConcatinatedString s(subStr, str);

    int strLen=s.length();

    vector<int> z (strLen);
    z[0]=strLen;
    zCalculation(s, z);

    for (size_t i=0; i<z.size(); ++i) {
        if(z[i] == subStr.size() && i > subStr.size()) {
            cout<< i - subStr.size() - 1 << " ";
        }
    };

    system("pause");
    return 0;
}